#!/bin/sh
#
# $OpenBSD: gdm.rc,v 1.41 2017/05/27 21:00:51 ajacoutot Exp $

daemon="${TRUEPREFIX}/sbin/gdm"

. /etc/rc.d/rc.subr

rc_bg=YES
rc_reload=NO

rc_pre() {
	# XXX OpenBSD needs an implementation of XDG_RUNTIME_DIR
	rm -rf /var/db/gdm/.cache/gnome-shell/runtime-state-*
}

rc_stop() {
	pkill -9 -xf "${pexp}"
	pkill -f gdm-session-worker
	pkill -u _x11 -f "^/usr/X11R6/bin/X.*/var/run/gdm"
	# _gdm owned processed may already be gone... or not
	pkill -u _gdm || return 0
}

# /etc/X11/xenodm/TakeConsole, fbtab(5)
rc_post() {
	if [ -c /dev/drm0 ]; then
		chown root /dev/drm0
	fi
	# XXX OpenBSD needs an implementation of XDG_RUNTIME_DIR
	rm -rf /var/db/gdm/.cache/gnome-shell/runtime-state-*
}

rc_cmd $1
